
/**
 * 
 */
//functinon delect()
//{
//$.ajax({
//   	 type: "POST",
//   	 data:"id="
//     url: "DispatchAction?method=doctor",
//      success: function(msg){
//   	   alert(msg[0].name);
//      },
//      datatype:"json"
//   });
//}
//window.onload = function ()
//{
//	var s=document.getElementById("insert");
//}
function delect(id)
{
	 $.ajax({
    	 type: "POST",
     	 url: "DispatchAction?method=delectdoctor",
       data: "id="+id,
       success: function(msg){
    	   if(msg){
    	  window.location.href="DispatchAction?method=doctor";
			 }
    	   else{
    		   alert("删除失败!");
    	   }
       },
//       datatype:JSON
    });
}
function up(id,id1,obj)
{
	var s=document.getElementsByName(id);
	for(var i=0;i<s.length;i++)
		{
		  s[i].setAttribute("contenteditable", "true");
		}
	obj.style.display="none";
	document.getElementById(id1).style.display="block";
}
function updata(id,id1,obj)
{	
	var ID=document.getElementById(id).innerText;
	var Data=new Array();
	var s=document.getElementsByName(id);
	for(var i=0;i<s.length;i++)
	{
	  Data[i]=s[i].innerText;
//	  alert(Data[i]);
	}
	for(var i=0;i<s.length;i++)
		{
		  s[i].setAttribute("contenteditable", "false");
		}
	obj.style.display="none";
	document.getElementById(id1).style.display="block";
	 $.ajax({
    	 type: "POST",
     	 url: "DispatchAction?method=updatadoctor",
       data: "id="+ID+"&name="+Data[0]+"&age="+Data[1]+"&department="+Data[2]+"&address="+Data[3]+"&TEL="+Data[4]+"&sex="+Data[5],
       success: function(msg){
    	   if(msg=="true")
    	   {
		    alert("修改成功");
		    window.location.href="DispatchAction?method=doctor";
		    return true;
		   }
		   else{
			   alert("修改failuer");
			   return false;
		   }
       },
//       datatype:JSON
    });
}
function insert()
{
	var oTest = document.getElementById("table");
	var newNode = document.createElement("tr");
	newNode.setAttribute("class", "insert");
	newNode.innerHTML = "<td ><div id="+"id"+" contenteditable="+"true"+"></div></td> <td><div id="+"name"+" contenteditable="+"true"+"></div></td> <td><div id="+"age"+" contenteditable="+"true"+"></div></td> <td><div id="+"department"+" contenteditable="+"true"+"></div></td> <td><div id="+"address"+" contenteditable="+"true"+"></div></td> <td><div id="+"TEL"+" contenteditable="+"true"+"></div></td> <td><div id="+"sex"+" contenteditable="+"true"+"></div></td> <td><button onclick="+"insertdata()"+">提交</button></td>";
	oTest.appendChild(newNode); 
	document.getElementById("table").appendChild("tr");
//	 $("#table1").
}
function insertdata()
{
		var data=new Array();
		 data[0]=document.getElementById("id").innerText;
		 data[1]=document.getElementById("name").innerText;
		 data[2]=document.getElementById("age").innerText;
		 data[3]=document.getElementById("department").innerText;
		 data[4]=document.getElementById("address").innerText;
		 data[5]=document.getElementById("TEL").innerText;
		 data[6]=document.getElementById("sex").innerText;
		 $.ajax({
	    	 type: "POST",
	     	 url: "DispatchAction?method=insertdoctor",
	       data: "id="+data[0]+"&name="+data[1]+"&age="+data[2]+"&department="+data[3]+"&address="+data[4]+"&TEL="+data[5]+"&sex="+data[6],
	       success: function(msg){
	    	   if(msg=="true")
	    	   {
			    alert("添加成功");
			    window.location.href="DispatchAction?method=doctor";
			    return true;
			   }
			   else{
				   alert("添加failuer");
				   return false;
			   }
	       },
//	       datatype:JSON
	    });
}
function printdiv()
{
	document.body.innerHTML=document.getElementById("printContainer").innerHTML;
	window.print();
}